package WizardTD;

import lombok.Data;
import processing.core.PApplet;

@Data
public class CountdownTimer {
    private float duration;  // 倒计时持续时间（毫秒）
    private int count = 0;
    private boolean start;

    public CountdownTimer(float duration) {
        this.duration = duration;
    }

    public CountdownTimer() {
    }

    public int getCurrentTime() {
        if (start) {
            this.count++;
            if (count % App.FPS == 0) {
                this.setDuration(Math.max(this.duration - 1, 0));
            }
        }
        return (int) this.getDuration();

    }

    boolean isFinished() {
        return getCurrentTime() == 0;
    }
}